/*  dgsh.h - dgsh - shell like bash
 * Autor        Diego Gomes da Silva    nUSP 7656467
 *              Alfredo Lima Porfirio   nUSP 7236614
 * Sistemas Operacionais 2
 * Professor Monaco
 * ICMC/USP
 */


#ifndef UTILS_H
#define UTILS_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/wait.h>


#define PROMPT_STRING "[DGSH]"

#define MAX_COMMAND_SIZE 1<<16
#define ARR_SIZE 1<<16

typedef char* Command[ARR_SIZE];

typedef struct {
    char userLine[MAX_COMMAND_SIZE];
    Command * command;
    char cwd[1024];
    int fd_out, fd_out2,fd_in, fd_in2;
    int pid, status, num_pipes;
    int continuous;
    int size_args ;
    int flag_out, flag_in;  
}ControlDgsh;


/* Report an error and exit. */

#define fatal(a) \
    do { fprintf (stderr, "%s: %s: %d: %s: %s\n", \
    a, __FILE__, __LINE__,\
    __PRETTY_FUNCTION__, strerror (errno)); \
    exit (EXIT_FAILURE);} while (0)

#endif/* UTILS_H */

